<?php include_once VIEWPATH.'common/dialog.php'; ?>
<script type="text/javascript">
    function on_submit(){
        var name = $("#name").val();
        if(!name){
            alert("名称不能为空");
            return false;
        }
        $('form').submit();
    }
    $("#label_add").on("hidden.bs.modal", function() {
        $(this).removeData("bs.modal");
    });
</script>

<div class="tab-pane active" id="horizontal-form">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true" aria-label="Close">×</button>
        <h5 class="modal-title"><?php echo $pageTitle;?></h5>
    </div>
    <form class="form-horizontal" name="form" id="form" action="index.php?c=<?php echo $_REQUEST['c'];?>&m=<?php echo $_REQUEST['m'];?>" name="form" method="post" enctype="multipart/form-data">
        <input type="hidden" name="id"  id="id" value="<?php echo $id; ?>"/>
        <input type="hidden" name="submits" value="1"/>
        <div class="form-group">
            <label for="name" class="col-sm-2 control-label">名称</label>
            <div class="col-sm-8">
                <input type="text" name="category[name]" value="<?php echo $category["name"];?>" class="form-control" id="name" placeholder="标签类型">
            </div>
            <div class="col-sm-2">
                <p class="help-block">不能为空</p>
            </div>
        </div>
        <div class="form-group">
            <label for="name" class="col-sm-2 control-label">分类</label>
            <div class="col-sm-8">
                <select name="category[parent_id]" id="parent_id" class="form-control">
                    <option value="0">请选择</option>
                    <?php foreach($categoryList as $categoryVal){ ?>
                        <option value="<?php echo $categoryVal["id"];?>" <?php echo $parent_id == $categoryVal["id"] || $category["parent_id"] == $categoryVal["id"] ? "selected" : "";?>><?php echo $categoryVal["name"];?></option>
                    <?php } ?>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="displayorder" class="col-sm-2 control-label">显示顺序</label>
            <div class="col-sm-8">
                <input type="text" name="category[displayorder]" value="<?php echo $category["displayorder"];?>" class="form-control" id="displayorder" placeholder="显示顺序">
            </div>
        </div>

        <div class="modal-footer">
            <button type="reset" class="btn btn-default" data-dismiss="modal">关闭</button>
            <button type="button" onclick="on_submit()" class="btn btn-primary">保存</button>
        </div>

    </form>
</div>